<template>
  <div class="search-wapper">
    <van-nav-bar
      title="指令指派"
      left-text="返回"
      left-arrow
      fixed
      @click-left="onClickLeft"
    >
      <van-icon name="arrow-left" slot="left" />
      <!--<van-icon name="search" slot="right"/>-->
    </van-nav-bar>
    <div class="search-content">
      <div class="search-content-head">
        <div class="custom-title1">
          <span class="user-line-input">{{ taskcodeId }}</span>
          <!--<span class="user-line-label">-->
          <!--<van-count-down :time="time"/>-->
          <!--</span>-->
        </div>

        <van-cell-group>
          <van-field
            v-model="userInfo.actions"
            label="AGV编号"
            @click="clickRight"
            placeholder="请选择AGV编号"
            disabled="false"
          />
        </van-cell-group>
      </div>

      <div class="button-content">
        <van-button
          type="primary"
          round
          style="width: 100%"
          @click="confirmAppoint"
          >确认指派</van-button
        >
      </div>
    </div>

    <van-action-sheet v-model="show" :actions="actions" @select="onSelect" />
  </div>
</template>

<script>
import { assignmentTask } from "@/api/Invtask.js";
export default {
  name: "InstructionAssignment",
  data() {
    return {
      taskcodeId: "",
      userInfo: {},
      show: false,
      actions: [{ name: "agv", subname: "agv" }]
    };
  },
  methods: {
    confirmAppoint() {
      assignmentTask(this.taskcodeId).then(res => {
        console.info("指派结束");
        this.$router.back(-1);
      });
    },
    onClickLeft() {
      this.$router.back(-1);
    },
    onSelect(item) {
      // 默认情况下，点击选项时不会自动关闭菜单
      // 可以通过 close-on-click-action 属性开启自动关闭
      this.show = false;
      // Toast(item.name);
      console.log("onSelect======", item.name);
      this.userInfo.actions = item.name;
    },
    clickRight() {
      console.log("=====clickRight===");
      this.show = true;
    }
  },
  created() {
    if (this.$route.query.taskcodeId != null) {
      this.taskcodeId = this.$route.query.taskcodeId;
    }
    console.info(this.taskcodeId);
  }
};
</script>

<style scoped lang="scss">
.search-wapper {
  position: relative;
  .search-content {
    position: relative;
    /*top: 46px;*/
    /*height: calc(100% - 50px);*/
    /*margin-bottom: 10px;*/
    top: 35%; /*偏移*/
    transform: translateY(-50%);
    .search-content-head {
      margin: 20px;
      padding: 5px;
      background: #fff;
      border-radius: 8px;
    }
    .custom-title1 {
      color: #000;
      background-color: #fff;
      padding: 10px 16px;
      font-weight: bold;
      span {
        font-size: 14px;
      }
    }
    .user-line-label {
      width: 85px;
      text-align: right;
      font-size: 14px;
      color: #606266;
      line-height: 1;
      /*padding: 0px 12px 10px 0;*/
      box-sizing: border-box;
      display: inline-block;
    }
    .user-line-input {
      position: relative;
      display: inline-block;
      font-size: 14px;
      vertical-align: top;
      width: calc(100% - 85px);
    }
  }
  .button-content {
    position: relative;
    /*top: 46px;*/
    margin-top: 20px;
    padding: 0px 20px;
  }
}
</style>
